package com.saas.day51;

import java.io.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

/**
 * value或者url-pattern属性可以用大括号来放置多个url，代表多个url指向同一个servlet
 * 当前servlet能够处理hello-servlet、hello-servlet02、hello-servlet03三个不同的请求
 * 意思是这三个请求都将交给这同一个HelloSevlet来处理
 */
@WebServlet(name = "helloServlet", value = {"/hello-servlet", "/hello-servlet02", "/hello-servlet03"})
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}